/******************************************************************/
/****** ************************************************************/   
#include "vtkInteractorStyle.h"
#include "vtkInteractorStyleTrackballActor.h"
#include "vtkTextMapper.h"
#include "vtkSmartPointer.h"
#include "vtkActor.h"
#include "vtkTextProperty.h"
#include "vtkProperty.h"
#include "vtkVariant.h"
class MouseInteractorStyle : public vtkInteractorStyleTrackballActor
{
public:
	static MouseInteractorStyle* New()
	{
		return new MouseInteractorStyle; 
	}

	MouseInteractorStyle()
	{
		pvtkTextMapper = vtkSmartPointer<vtkTextMapper>::New();
		pActor = vtkSmartPointer<vtkActor>::New();
	}
	~MouseInteractorStyle()
	{
	}
	void SetActor(vtkActor *actor) 
	{
		this->pActor = actor; 
	}
	void SetTextMapper(vtkTextMapper *mapper) 
	{
		this->pvtkTextMapper = mapper; 
	}
	void OnLeftButtonDown()
	{
		pActor->GetProperty()->SetColor(0,1.0,0); //(R,G,B)
		vtkInteractorStyleTrackballActor::OnLeftButtonDown();
	}
	void OnLeftButtonUp()
	{
		pActor->GetProperty()->SetColor(0,0.8,0); //(R,G,B)
		vtkInteractorStyleTrackballActor::OnLeftButtonUp();
	}
	void OnRightButtonDown()
	{
	}
	void OnMiddleButtonDown()
	{
	}
	void OnMouseMove()
	{
		double *i = pActor->GetPosition();

		std::string message = " ( ";
		message += vtkVariant( i[0] ).ToString();
		message += ", ";
		message += vtkVariant( i[1] ).ToString();
		message += ", ";
		message += vtkVariant( i[2] ).ToString();
		message += " ) ";


		this->pvtkTextMapper->SetInput(message.c_str() );
		this->pvtkTextMapper->GetTextProperty()->SetColor(1,1,0);
		this->pvtkTextMapper->GetTextProperty()->SetFontSize(12);


		// Forward events
		vtkInteractorStyleTrackballActor::OnMouseMove();
	}
	vtkSmartPointer<vtkActor> pActor;
	vtkSmartPointer<vtkTextMapper> pvtkTextMapper;
};
